package com.blog.zip.mapper;

import com.blog.zip.bean.User;

import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

//@Mapper
public interface UserMapper {
    @Select("select * from zip_blog_user where zid=#{id}")
    public User getUserById(Integer id);

    @Select("select * from b3_solo_user where oid=#{id}")
    public User getUserByIdV2(String id);

    @Select("select * from b3_solo_user")
    public List<Map<String,Object>> getUserList();

    @Select("UPDATE b3_solo_user SET userURL = #{link},userAvatar=#{avatar}," +
        "userB3Key = #{b3Key},userPassword = #{password} where oId = #{id}")
    public void  updateUserList(Map m);


    @Select("select * from zip_blog_user where userName=#{name}")
    public User getUserByName(String name);

    @Select("select * from b3_solo_user where userName=#{name} and userPassword=#{password}")
    public User getUserByPassword(String name,String password);

    @Delete("delete from zip_blog_user where uid=#{id}")
    public int deleteUserById(Integer id);

    @Options(useGeneratedKeys = true,keyProperty = "zid")
    @Insert("insert into zip_blog_user(userName) values(#{userName})")
    public int insertUser(User user);

    @Update("update zip_blog_user set uname=#{uname} where uid=#{uid}")
    public int updateUser(User user);

    public int getBlogInfo(int type);

    @Select("SELECT * FROM `b3_solo_option` WHERE optionCategory = CONCAT('','preference','')")
    public List<Map<String,Object>> getBlogPreference(String type);

    @Update("UPDATE b3_solo_option SET optionValue = #{value} where oid = #{key} ")
    public void  updateBlogInfo(Map<String,Object> map);
}
